package net.zui;

import java.awt.Color;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.RenderingHints.Key;
import java.util.HashMap;
import java.util.Map;

import net.zui.util.UComm;
import net.zui.util.UDraw;

/**
 * 本框架的所有默认设置
 * <br /><br />
 * <b>作者:</b>张天文 <br />
 * <b>日期:</b>2021年4月19日上午11:29:12<br />
 * @date
 */
public class Option {
	/** 默认标题 */
	public static final String title="ZUI 0.0.1 for ztw";
	/** 默认时间格式化字符串 */
	public static final String def_data_format="yyyy-MM-dd kk:mm:ss";
	public static final Color baseBackColor=new Color(0, 0, 0, 0);
	public static final Map<Key, Object> renderingHints=new HashMap<Key, Object>(){
		private static final long serialVersionUID = 1L;
	{
		put(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
		put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	}};
	public static int padding = 3;
	
	/** 背景色,默认苹果绿 */
	private static Color backColor=new Color(199, 237, 204);
	/** 前景色,默认深灰色 */
	private static Color color=UDraw.web("333");
	/** 边框颜色 */
	private static Color borderColor=UDraw.web("ccc");
	/** 边框鼠标移入颜色 */
	private static Color mouseInColor=UDraw.antiColor(color);
	/** 默认字体 */
	private static Font font=getFont(14, "Source Code Pro","DejaVu Sans Mono","Ubuntu Mono","Anonymous Pro","Droid Sans Mono","Menlo","Monaco","Consolas",
			"Inconsolata","Courier","monospace","PingFang SC","Microsoft YaHei","sans-serif");
	public static Font getFont(int fontSize,String...fontNames) {
		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		Font[] fonts = environment.getAllFonts();
		Font f = null;
		outer:for(Font font:fonts) {
			for(String s:fontNames) {
				if(UComm.equals(font.getFamily(), s)) {
					f=font;
					break outer;
				}
			}
		}
		if(f==null) {
			f=new Font("黑体",0,fontSize);
		}
		return f;
	}
	
	public static Color getBackColor() {
		return backColor;
	}
	public static void setBackColor(Color backColor) {
		Option.backColor = backColor;
	}
	public static Color getColor() {
		return color;
	}
	public static void setColor(Color color) {
		Option.color = color;
	}
	public static Color getBorderColor() {
		return borderColor;
	}
	public static void setBorderColor(Color borderColor) {
		Option.borderColor = borderColor;
	}
	public static Color getMouseInColor() {
		return mouseInColor;
	}
	public static void setMouseInColor(Color mouseInColor) {
		Option.mouseInColor = mouseInColor;
	}
	public static Font getFont() {
		return font;
	}
	public static void setFont(Font font) {
		Option.font = font;
	}
}
